import json

class Post:
    def __init__(self, post_id, category, title, text):
        self.__id = post_id
        self.__title = title
        self.__category = category
        self.__text = text
    
    def get_post_id(self):
        return self.__id
    
    def get_category(self):
        return self.__category
    
    def get_text(self):
        return self.__text
    
    def get_title(self):
        return self.__title


class PostJsonEncoder(json.JSONEncoder):
    def default(self, post):
        data = dict()
        data['id'] = post.get_post_id()
        data['title'] = post.get_title()
        data['text'] = post.get_text()
        data['category'] = post.get_category()
        return data
    
class PostRepository:
    def load_all_posts(self):
        return POSTS
    

POSTS = [Post(0, "shell", "Determine port status", """
PORT = 8000<br/>
if [ "tcp" != "`netstat -ln | grep $PORT | cut -d' ' -f1`" ]<br/>
then<br/>
    echo "$PORT is in use"<br/>
fi
"""), Post(1, "shell", "VIM config for Python", """
set tabstop=4<br/>
set expandtab
""")]
